#!/usr/bin/env python
import os
import django

# 设置Django环境
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wealth_backend.settings')
django.setup()

from users.models import User
from rest_framework.authtoken.models import Token

users = User.objects.all()
print(f'Total users: {users.count()}')

for user in users[:5]:  # 只显示前5个用户
    print(f'User: {user.username}, Email: {user.email}, Active: {user.is_active}')
    try:
        token = Token.objects.get(user=user)
        print(f'  Token: {token.key}')
    except Token.DoesNotExist:
        print('  No token found')
        # 为用户创建token
        token = Token.objects.create(user=user)
        print(f'  Created new token: {token.key}')
    print()